#!/bin/bash

streamCount=$1
echo "测试目标路数：${streamCount}"

inputScheam="rtmp"
inputHost="192.168.1.162"
inputPort="1934"

outputScheam="rtmp"
outputHost="192.168.1.162"
outputPort="1934"

inputUrl="${inputScheam}://${inputHost}:${inputPort}/live/test"

pusher="/root/pusher_ZLMediaKit/build/pusher"

echo "-----------------------------------------------------------"
for((i=0;i<$streamCount;i++))
do
    outputUrl="${outputScheam}://${outputHost}:${outputPort}/live/ch${i}";
    echo "${pusher} ${inputUrl} ${outputUrl} 1>/dev/null 2>/dev/null &"
    ${pusher} ${inputUrl} ${outputUrl} 1>/dev/null 2>/dev/null &
    # top -b -n 1 | head -n 5
    sleep 1
    echo "-----------------------------------------------------------"
done

echo "开始记录使用情况..."

echo "-----------------------------------------------------------"
for((i=0;i<3600;i++))
do
    # top -b -n 1 | head -n 5
    # echo "-----------------------------------------------------------"
    # top -b -n 1 | grep ffmpeg
    # echo "-----------------------------------------------------------"
    top -b -n 1 | grep ffmpeg | wc
    echo "-----------------------------------------------------------"
    # free -h
    # echo "-----------------------------------------------------------"
    sleep 5
done

# ffmpeg -i "rtsp://admin:julong123@192.168.1.87:554/video1" -c copy -f flv "rtmp://127.0.0.1:1934/live/test"

# ffmpeg -i "rtsp://admin:julong123@192.168.1.87:554/video1" -c copy -f flv "rtmp://127.0.0.1:10000/live/test" >/dev/null 2>&1

# ffmpeg -i rtmp://192.168.1.152/live/level3-shelf -c:v copy -c:a copy -f flv rtmp://192.168.1.164:1934/live/ch0
